<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link href="./resources/css/default.css" rel="stylesheet"
		type="text/css" />
	<link href="./resources/css/cssLayout.css" rel="stylesheet"
		type="text/css" />
	<title>Sabatec Manutenção &amp; Construção Civil</title>
	<script type="text/javascript">
            function handleLoginRequest(xhr, status, args) {
                if (args.validationFailed || !args.loggedIn) {
                    PF('dlg').jq.effect("shake", {times: 5}, 100);
                }
                else {
                    PF('dlg').hide();
                    $('#loginLink').fadeOut();
                }
            }
        </script>
	<script type="text/javascript">
            function handleComplete(args) {
                //alert(args.error);  
                if (!args.error) {
                    dlg2.show();
                }


            }


        </script>
</h:head>

<h:body>

	<div id="top">
		<ui:insert name="top">
			<ui:insert name="top">
				<center>
					<img src="img/logo_sabate.jpg" width="740" height="266"
						alt="logo_sabate" />
				</center>
			</ui:insert>
		</ui:insert>
	</div>

	<div id="content" class="center_content">
		<ui:insert name="content">
			<h:form id="formTop">
				<p:breadCrumb>
					<p:menuitem value="home" url="index.xhtml" />
					<p:menuitem value="Cadastro de Serviço" url="cadastraServico.xhtml" />
				</p:breadCrumb>

				<p:panelGrid columns="4" style="width: 100%">
					<f:facet name="header">  
        Cadastro de Serviço  
    </f:facet>

					<h:outputLabel value="Cliente: *" />
					<p:inputText
						value="#{requestServiceSabatecBean.requestService.cliente}" />

					<h:outputLabel value="Emprendimento: *" />
					<p:inputText
						value="#{requestServiceSabatecBean.requestService.emprendimento}" />

					<h:outputLabel value="Torre: *" />
					<p:inputText
						value="#{requestServiceSabatecBean.requestService.torre}" />

					<h:outputLabel value="Unidade: *" />
					<p:inputText
						value="#{requestServiceSabatecBean.requestService.unidade}" />

					<h:outputLabel value="Serviço Concluido: *" />
					<p:selectBooleanCheckbox
						value="#{requestServiceSabatecBean.requestService.servicoconcluido}" />

					<h:outputLabel value="Data: *" />
					<p:calendar
						value="#{requestServiceSabatecBean.requestService.data}"
						id="popupButtonCal" showOn="button" />

					<h:outputLabel value="Motivo: *" />
					<p:inputTextarea rows="5" cols="25"
						value="#{requestServiceSabatecBean.requestService.motivo}"
						queryDelay="750" minQueryLength="4" />

					<h:outputLabel value="Descrição do Serviço: *" />
					<p:inputTextarea rows="5" cols="25"
						value="#{requestServiceSabatecBean.requestService.descrservico}"
						queryDelay="750" minQueryLength="4" />

					<f:facet name="footer">
						<center>
							<p:commandButton value="Salvar" ajax="true" icon="ui-icon-disk"
								action="#{requestServiceSabatecBean.salva(requestServiceSabatecBean.requestService)}"
								update=":form:tbl :form:growl" style="margin:0;" />
						</center>
					</f:facet>
				</p:panelGrid>

			</h:form>

			<h:form id="form">
				<p:growl id="growl" showDetail="true" life="4000" />
				<p:dataTable id="tbl" var="servicoList"
					value="#{requestServiceSabatecBean.requestServicos}"
					paginator="true" rows="5">

					<p:column>
						<f:facet name="header">
							<h:outputText value="ID" />
						</f:facet>
						<h:outputText value="#{servicoList.id}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Cliente" />
						</f:facet>
						<h:outputText value="#{servicoList.cliente}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Emprendimento" />
						</f:facet>
						<h:outputText value="#{servicoList.emprendimento}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Torre" />
						</f:facet>
						<h:outputText value="#{servicoList.torre}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Unidade" />
						</f:facet>
						<h:outputText value="#{servicoList.unidade}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Data do Serviço" />
						</f:facet>
						<h:outputText value="#{servicoList.data}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Descrição" />
						</f:facet>
						<h:outputText value="#{servicoList.descrservico}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Serviço Concluido" />
						</f:facet>
						<h:selectBooleanCheckbox value="#{servicoList.servicoconcluido}"
							disabled="true" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Motivo" />
						</f:facet>
						<h:outputText value="#{servicoList.motivo}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>

						<p:commandButton ajax="false"
							action="#{obraExcecSabatecBean.getExecObra(servicoList)}"
							icon="ui-icon-person" title="Cadastro Mão de Obra" />

						<p:commandButton ajax="false"
							
							icon="ui-icon-wrench" title="Cadastro de Material" />

						<p:commandButton id="selectButton" update=":form:display"
							oncomplete="handleComplete(args)" icon="ui-icon-pencil" title="Alterar Cadastro">
							<f:setPropertyActionListener
								target="#{requestServiceSabatecBean.requestService}"
								value="#{servicoList}" />
						</p:commandButton>

						<p:commandButton ajax="true"
							action="#{requestServiceSabatecBean.exclui(servicoList)}"
							icon="ui-icon-trash" update=":form:tbl :form:growl" title="Excluir Cadastro"/>
					</p:column>
				</p:dataTable>
				<p:dialog id="content" header="Editando Informação" modal="true"
					widgetVar="dlg2" height="auto" draggable="false" width="auto%"
					closable="true">
					<h:panelGrid id="display" columns="1" cellpadding="2"
						style="margin:0 auto;">
						<p:column>
							<h:inputHidden
								value="#{requestServiceSabatecBean.requestService.id}" />
						</p:column>
						<p:column>
							<h:outputText value="Cliente: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{requestServiceSabatecBean.requestService.cliente}" />
						</p:column>
						<p:column>
							<h:outputText value="Empreendimento: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{requestServiceSabatecBean.requestService.emprendimento}" />
						</p:column>
						<p:column>
							<h:outputText value="Torre: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{requestServiceSabatecBean.requestService.torre}" />
						</p:column>
						<p:column>
							<h:outputText value="Unidade: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{requestServiceSabatecBean.requestService.unidade}" />
						</p:column>
						<p:column>
							<h:outputText value="Data: " />
						</p:column>
						<p:column>
							<p:calendar
								value="#{requestServiceSabatecBean.requestService.data}"
								id="popupButtonCal" showOn="button" />
						</p:column>
						<p:column>
							<h:outputText value="Descrição do Serviço: " />
						</p:column>
						<p:column>
							<p:inputTextarea rows="5" cols="25"
								value="#{requestServiceSabatecBean.requestService.descrservico}"
								queryDelay="750" minQueryLength="4" />
						</p:column>
						<p:column>
							<h:outputText value="Serviço Concluido: " />
						</p:column>
						<p:column>
							<p:selectBooleanCheckbox
								value="#{requestServiceSabatecBean.requestService.servicoconcluido}" />
						</p:column>
						<p:column>
							<h:outputText value="Motivo: " />
						</p:column>
						<p:column>
							<p:inputTextarea rows="5" cols="25"
								value="#{requestServiceSabatecBean.requestService.motivo}"
								queryDelay="750" minQueryLength="4" />
						</p:column>
						<p:commandButton icon="ui-icon-disk" ajax="true"
							action="#{requestServiceSabatecBean.salvaUpdate(requestServiceSabatecBean.requestService)}"
							update=":form:tbl :form:growl" />

					</h:panelGrid>
				</p:dialog>
			</h:form>
			<h:form>
				<center>
					<h:panelGrid columns="1">
						<p:panel header="Exportar Serviços Excel">
							<center>
								<h:commandLink>
									<p:graphicImage value="img/csv.png" />
									<p:dataExporter type="xls" target="tbl" fileName="servicos" />
								</h:commandLink>
								<h:commandLink>
									<p:graphicImage value="img/pdf.png" />
									<p:dataExporter type="pdf" target="tbl" fileName="servicos" />
								</h:commandLink>
							</center>
						</p:panel>
					</h:panelGrid>
				</center>
			</h:form>
		</ui:insert>
	</div>

	<div id="bottom">
		<ui:insert name="bottom">
			<img src="img/background_bottom.jpg" width="6" height="30" />
		</ui:insert>
	</div>

</h:body>

</html>
